package main;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

import javax.swing.JWindow;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/*http://superuser.com/questions/268521/can-i-sleep-one-of-the-displays-on-a-dual-monitor-setup-running-windows-7*/

public class SecondWindow extends JWindow
{
   private static final long serialVersionUID = 3493635987367217622L;

   private final int _screen;

   public SecondWindow(int i_screen) {
	   super ();
	   _screen = i_screen;
}

public void begin()
   {
      GraphicsDevice gda[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
      GraphicsDevice gd = gda[_screen];
      getContentPane().setBackground(Color.black);

/*      for (GraphicsDevice gdTmp : gda)
      {
         System.out.print( (gd == gdTmp) ? "->" : "  ");
         System.out.println( 
                "Screen(" + gdTmp.getDefaultConfiguration().getDevice().getIDstring() +")"
                +" "+ gdTmp.getDefaultConfiguration().getBounds() );
      }
*/
      
      // Blank Cursor
      BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
      Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
    		  cursorImg, new Point(0, 0), "blank cursor");
      this.getContentPane().setCursor(blankCursor);

      Rectangle bounds = gd.getDefaultConfiguration().getBounds();
      setLocation(bounds.getLocation());
      setSize(bounds.getSize());
      setAlwaysOnTop(true);

      validate();
      setVisible(true);
   }

   /**
    * @param args
    * @throws Exception 
    */

   public static void blabla(int screen)
   {
      try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (InstantiationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IllegalAccessException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (UnsupportedLookAndFeelException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
      SecondWindow dimmer = new SecondWindow(screen);
      dimmer.begin();
   }


}